
function formatTimestamp(timestamp, format = 'YYYY年MM月DD日') {
  const date = new Date(timestamp);
  const year = date.getFullYear();
  const month = String(date.getMonth() + 1).padStart(2, '0');
  const day = String(date.getDate()).padStart(2, '0');
  
  return format.replace('YYYY', year).replace('MM', month).replace('DD', day);
}

// 判断日期是三个月内的。
function isWithinLastThreeMonths(timestamp) {
  const currentTimestamp = Date.now();
  const threeMonthsInMs = 3 * 30 * 24 * 60 * 60 * 1000; // 三个月的毫秒数
  
  return currentTimestamp - timestamp <= threeMonthsInMs;
}

module.exports = {
  formatTimestamp,
  isWithinLastThreeMonths
};
